package com.elinkway.infinitemovies.view;

import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.RelativeLayout;

/**
 * Created by liuxiaojiang on 2017/8/18.
 */

public class ClickRelativeLayout extends RelativeLayout {
    public float mDownX = 0;
    public float mDownY = 0;
    public float mUpX = 0;
    public float mUpY = 0;
    public ClickRelativeLayout(Context context) {
        super(context);
    }

    public ClickRelativeLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ClickRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public ClickRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                //点击坐标x
                mDownX = event.getX() ;
                //点击坐标y
                mDownY = event.getY() ;
                break;
            case MotionEvent.ACTION_UP:
                mUpX = event.getX() ;
                mUpY = event.getY() ;
                break;
            default:
                break;
        }
        return super.onTouchEvent(event);
    }

}
